/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package core.proxy;


import core.descriptors.TaskDescriptor;
import core.descriptors.WorkerDescriptor;
import core.discovery.WorkerDiscovery;
import core.util.COREServiceRegistry;
import core.worker.Address;
import org.apache.log4j.Logger;

/**
 *
 * @author Vincenzo Merlo, Scuderi Giovanni Luca, Paolo Giuffrida
 *
 */
public class WorkerDiscoveryProxyP2P extends WorkerDiscoveryProxy {

    private final Logger logger = COREServiceRegistry.getLogger(WorkerDiscoveryProxyP2P.class.toString());
    protected WorkerDiscovery workerDiscovery;

    /**
     *
     */
    public WorkerDiscoveryProxyP2P() {
        super();
        logger.trace(" costructor");
        workerDiscovery = WorkerDiscovery.getInstance();
    }

    /**
     *
     * @param td
     * @return
     */
    @Override
    public Address getWorker(TaskDescriptor td) {
        logger.trace("getWorker");
        return COREServiceRegistry.getDiscovery().getWorker(td);
    }

    /**
     * @param index
     * @param wd
     * @return
     */
    @Override
    public int updateWorker(int index, WorkerDescriptor wd) {
        logger.trace("updateWorker");
        return COREServiceRegistry.getDiscovery().updateWorker(index, wd);
    }

    /**
     *
     * @param wd
     * @return
     */
    @Override
    public int addWorker(WorkerDescriptor wd) {
        logger.trace("addWorker");
        return COREServiceRegistry.getDiscovery().addWorker(wd); //TODO FIX!
    }

    /**
     *
     * @return
     */
    @Override
    public String toString() {
    	return WorkerDiscoveryProxyP2P.class.getSimpleName();
    }

}
